﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.IsolatedStorage;

namespace IsolatedStorageUseTime
{
    class IsoStorage
    {
        static void Main()
        {
            IsolatedStorageFile userStorage = IsolatedStorageFile.GetUserStoreForAssembly();
            using (userStorage)
            {
                IsolatedStorageFileStream stream = new IsolatedStorageFileStream("LastTimeUsed.txt",
                    FileMode.OpenOrCreate, userStorage);
                using (stream)
                {
                    TextReader reader = new StreamReader(stream);
                    string lastTimeUsed = reader.ReadToEnd();
                    Console.WriteLine("Last usage {0}", lastTimeUsed);

                    stream.SetLength(0);
                    TextWriter writer = new StreamWriter(stream);
                    using (writer)
                    {
                        writer.Write(DateTime.Now);
                    }
                }
            }
        }
    }
}
